package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysEnviromentDetection;
import com.ruoyi.system.service.ISysEnviromentDetectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统环境检测Controller
 * 
 * @author ruoyi
 * @date 2023-06-09
 */
@RestController
@RequestMapping("/system/detection")
public class SysEnviromentDetectionController extends BaseController
{
    @Autowired
    private ISysEnviromentDetectionService sysEnviromentDetectionService;


    /**
     * 查询系统环境检测列表
     */
    @PreAuthorize("@ss.hasPermi('system:detection:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysEnviromentDetection sysEnviromentDetection)
    {
        startPage();
        List<SysEnviromentDetection> list = sysEnviromentDetectionService.selectSysEnviromentDetectionList(sysEnviromentDetection);
        System.out.println(sysEnviromentDetectionService.getCount()+"============================");
        return getDataTable(list);
    }

    /**
     * 导出系统环境检测列表
     */
    @PreAuthorize("@ss.hasPermi('system:detection:export')")
    @Log(title = "系统环境检测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysEnviromentDetection sysEnviromentDetection)
    {
        List<SysEnviromentDetection> list = sysEnviromentDetectionService.selectSysEnviromentDetectionList(sysEnviromentDetection);
        ExcelUtil<SysEnviromentDetection> util = new ExcelUtil<SysEnviromentDetection>(SysEnviromentDetection.class);
        util.exportExcel(response, list, "系统环境检测数据");
    }

    /**
     * 获取系统环境检测详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:detection:query')")
    @GetMapping(value = "/{sedCode}")
    public AjaxResult getInfo(@PathVariable("sedCode") String sedCode)
    {
        return success(sysEnviromentDetectionService.selectSysEnviromentDetectionBySedCode(sedCode));
    }

    /**
     * 新增系统环境检测
     */
    @PreAuthorize("@ss.hasPermi('system:detection:add')")
    @Log(title = "系统环境检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysEnviromentDetection sysEnviromentDetection)
    {
        return toAjax(sysEnviromentDetectionService.insertSysEnviromentDetection(sysEnviromentDetection));
    }

    /**
     * 修改系统环境检测
     */
    @PreAuthorize("@ss.hasPermi('system:detection:edit')")
    @Log(title = "系统环境检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysEnviromentDetection sysEnviromentDetection)
    {
        return toAjax(sysEnviromentDetectionService.updateSysEnviromentDetection(sysEnviromentDetection));
    }

    /**
     * 删除系统环境检测
     */
    @PreAuthorize("@ss.hasPermi('system:detection:remove')")
    @Log(title = "系统环境检测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sedCodes}")
    public AjaxResult remove(@PathVariable String[] sedCodes)
    {
        return toAjax(sysEnviromentDetectionService.deleteSysEnviromentDetectionBySedCodes(sedCodes));
    }
}
